<?php

namespace app\admin\validate;

use think\Validate;

class Comments extends Validate
{
    protected $rule = [
        'work_id' => 'require',
        'work_rob_id' => 'require',
        'associated_id' => 'require',
        'comments' => 'require',
        'score' => 'require|checkScore',
    ];

    protected $scene=[
        'commentUser'=>['work_id','work_rob_id','associated_id','comments','score'],
    ];

    protected $message = [
        'work_id' => '零活id不能为空',
        'work_rob_id' => '抢活id不能为空',
        'associated_id' => '被评价者id不能为空',
        'comments' => '评价内容不能为空',
        'score' => '评分不能为空',
    ];
    protected function checkScore($value){
        if($value==0){
            return '评分不能小于1';
        }
        if($value>5){
            return '评分不能大于5';
        }
        return true;
    }
}
